﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TStart
{
    public partial class frmConfig : Form
    {
        public frmConfig()
        {
            InitializeComponent();

            this.TopMost = true;
        }

        private void FrmConfig_Load(object sender, EventArgs e)
        {
            checkBoxAutoStart.Checked = Misc.IsAutoStartUp();
        }

        public void ConfigSet(TStartConfig config)
        {
            checkBoxTitle.Checked = config.Title != "TStart";
            textBoxTitle.Enabled = checkBoxTitle.Checked;
            textBoxTitle.Text = config.Title;
            comboBoxView.SelectedIndex = config.View;
            checkBoxHideAfterOpen.Checked = config.HideAfterOpen;
        }

        public TStartConfig ConfigGet()
        {
            TStartConfig config = new TStartConfig();

            config.Title = textBoxTitle.Text;
            config.View = comboBoxView.SelectedIndex;
            config.HideAfterOpen = checkBoxHideAfterOpen.Checked;

            return config;
        }

        private void CheckBoxTitle_CheckedChanged(object sender, EventArgs e)
        {
            if(!checkBoxTitle.Checked)
            {
                textBoxTitle.Text = "TStart";
            }

            textBoxTitle.Enabled = checkBoxTitle.Checked;
        }

        private void ButtonOK_Click(object sender, EventArgs e)
        {
            Misc.ChangeAutoStartUp(checkBoxAutoStart.Checked);

            DialogResult = DialogResult.OK;
        }
    }
}
